async function register() {
    let form = document.querySelector('.register-form')
    let data = serialize(form, { hash: true, empty: true })
    //验证输入账号密码是否为空
    let { username, password } = data
    if (username.trim() === '' || password.trim() === '') {
        toast('用户名或密码不能为空')
        return
    }
    try {
        let res = await axios.post('/api/register', data)
        console.log(res)
        if (res.code === 10000) {
            toast('注册成功')
            setTimeout(() => {
                location.href = './login.html'
            },666)
        }else{
            toast(res.message)
            form.reset()
        }
    } catch (err) {
        console.dir(err)
        toast(err.response.data.message)
        form.reset()
        return
    }
}
let btn = document.querySelector('#btn-register')
btn.addEventListener('click', register)
let toLogin= document.querySelector('.small')